package com.droowa.model.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.droowa.domain.BoardClass;
import com.droowa.domain.BoardList;
import com.droowa.domain.BoardManagement;
import com.droowa.domain.BoardOrder;
import com.droowa.domain.BoardSort;
import com.droowa.model.dao.BoardManagementDAO;
import com.droowa.model.dao.BoardPaperDAO;

@Service
public class BoardManagementServiceImpl implements BoardManagementService {

	@Autowired
	BoardManagementDAO dao;
	@Autowired
	BoardPaperDAO paperDAO;
	
	@Override
	public List<BoardClass> searchBoardClass() throws SQLException {
		return dao.searchBoardClass();
	}
	
	@Override
	public List<BoardManagement> searchBoardManagement() throws SQLException {
		return dao.searchBoardManagement();
	}
	
	@Override
	public BoardManagement searchBoardManagementId(int boardId)
			throws SQLException {
		return dao.searchBoardManagementId(boardId);
	}

	@Override
	public int createBoardPaper(int boardId) throws SQLException {
		return dao.createBoardPaper(boardId);
	}

	
	@Override
	public int createBoardPaperSequence(int boardId) throws SQLException {
		return dao.createBoardPaperSequence(boardId);
	}

	@Override
	public int insertBoardManagement(BoardManagement bm) throws SQLException {
		return dao.insertBoardManagement(bm);
	}

	@Override
	public List<BoardList> searchBoardList() throws SQLException {
		List<BoardList> bll = dao.searchBoardList();
		for(int i=0; i < bll.size(); i++) {
			BoardList bl = bll.get(i);
			bl.setAllPaper(paperDAO.selectTotalContent(bl.getBoardId()));
		}
		return bll;
	}

	@Override
	public int insertBoardOrder(BoardOrder bo) throws SQLException {
		return dao.insertBoardOrder(bo);
	}
	
	@Override
	public int insertBoardFirstOrder(BoardOrder bo) throws SQLException {
		return dao.insertBoardFirstOrder(bo);
	}

	@Override
	public int updateBoardManagementById(BoardManagement bm) throws SQLException {
		return dao.updateBoardManagementById(bm);
	}

	@Override
	public int deleteBoardManagementById(int boardId) throws SQLException {
		return dao.deleteBoardManagementById(boardId);
	}

	@Override
	public int dropBoardPaper(int boardId) throws SQLException {
		return dao.dropBoardPaper(boardId);
	}

	@Override
	public int dropBoardPaperSequence(int boardId) throws SQLException {
		return dao.dropBoardPaperSequence(boardId);
	}

	@Override
	public List<BoardSort> searchSortList() throws SQLException {
		return dao.searchSortList();
	}

	@Override
	public int updateBoardSort(int[] sort) throws SQLException {
		return dao.updateBoardSort(sort);
	}

	@Override
	public List<BoardSort> searchOpenList() throws SQLException {
		return dao.searchOpenList();
	}	
	
	
	
}
